<?php
use Menory\Standard\Error;
use Menory\Unit\HttpClient\Adapter\CUrl;
use Menory\Unit\HttpClient\Response;
use PHPUnit\Framework\TestCase;

require  "../vendor/autoload.php";

class HttpClientTest extends TestCase {

    /**
     * @test
     */
    public function get() {

        $httpClient = new CUrl();
        $url = "http://192.168.1.107:9516/test/html";
        /**
         * @var Response $response
         * @var Error $err
         */
        list($response, $err) = $httpClient->send($url, "get");
        if ($err !== null) {
            $this->assertInstanceOf(Error::class, $err);
            $this->assertEquals("[7] Failed to connect to 192.168.1.107 port 9516: Connection refused"
                , $err->getMessage());
            return ;
        }
        $this->assertEquals(200, $response->getStatus());
        $this->assertNotNull($response->getBody());

    }

}